﻿Imports GT = Gadgeteer
Imports GTM = Gadgeteer.Modules
Imports Gadgeteer.Modules.GHIElectronics
Imports Gadgeteer.Modules.Edu.Ghi


Namespace GadgeteerApp1
    Partial Public Class Program

        ' This is run when the mainboard is powered up or reset. 
        Public Sub ProgramStarted()
            Const dot = 300  ' dot
            Const dash = 900  ' dash is three times as long as a dot
            Const rest = 900 ' rest between letters is three times as long as a dot
            Const gap = 300 ' gap between sounds is as long as one dot
            Const frequency = 300 ' chosen frequency

            Dim melody As Melody = New Melody()
            Debug.Print("Program Started")
            Dim newWord As String = "HELLO"

            '•	H  - dot dot dot dot 
            '•	E  - dot
            '•	L – dot dash dot dot
            '•	L – dot dash dot dot
            '•	O – dash dash dash


            For count As Integer = 0 To newWord.Length() - 1
                Debug.Print(newWord(count))

                Select Case newWord(count)
                    Case "H"  '  
                        For counter As Integer = 1 To 4
                            melody.Add(frequency, dot)
                            melody.Add(0, gap)
                        Next
                    Case "E"  '  
                        melody.Add(frequency, dot)
                        melody.Add(0, gap)
                    Case "L"  '                     
                        melody.Add(frequency, dot)
                        melody.Add(0, gap)
                        melody.Add(frequency, dash)
                        melody.Add(0, gap)
                        melody.Add(frequency, dot)
                        melody.Add(0, gap)
                        melody.Add(frequency, dot)
                        melody.Add(0, gap)
                    Case "O"
                        For counter As Integer = 1 To 3
                            melody.Add(frequency, dash)
                            melody.Add(0, gap)
                        Next
                End Select
                melody.Add(0, rest)

            Next
            tunes.Play(melody)



        End Sub
         

        ' If you want to do something periodically, declare a GT.Timer by uncommenting the below line
        '   and then use the dropdown boxes at the top of this window to generate a Tick event handler.
        ' Dim WithEvents timer As GT.Timer = new GT.Timer(1000)  ' every second (1000ms)

    End Class
End Namespace